import { createRouter, createWebHistory,createWebHashHistory } from "vue-router";

import NProgress from "nprogress";
import "nprogress/nprogress.css";

const routes = [
	{
		path: "/login",
		name: "login",
		component: () => import("../views/login/index.vue"),
		meta: {
			title: "登录页",
		},
  },
  {
    path: "/test",
    name: "test",
    meta: {
			title: "test"
		},
    component:() => import("../views/test.vue")
  },
  {
		path: "/",
		component: () =>
			import("../Layout/index.vue"),
		redirect: "/site",
		meta: {
			title: "场馆"
		},
		children: [{
			path: "/site",
			component: () =>
				import ("../views/site/index.vue"),
			meta: {
				title: "场馆列表"
			}
		},{
			path: "/siteRegister",
			component: () =>
				import ("../views/site/siteRegister.vue"),
			meta: {
				title: "场馆注册"
			}
		},{
			path: "/siteModify",
			component: () =>
				import ("../views/site/siteModify.vue"),
			meta: {
				title: "场馆修改"
			}
		},
		]
  },
  {
		path: "/bracelet",
		component: () =>
			import("../Layout/index.vue"),
		meta: {
			title: "用户手环"
		},
		children: [
    {
      path: "/bracelet",
      component: () =>
        import ("../views/bracelet/index.vue"),
      meta: {
        title: "用户手环"
      }
      }
		]
  },
  {
		path: "/swimTicket",
		component: () =>
			import("../Layout/index.vue"),
		meta: {
			title: "泳票"
		},
		children: [{
			path: "/swimTicket",
			component: () =>
				import ("../views/swimTicket/index.vue"),
			meta: {
				title: "泳票"
			}
		}
		]
	},
  
	{
		path: "/developer",
		component: () => import("../Layout/index.vue"),
		meta: {
			title: "开放平台"
		},
		children: [{
			path: "/developer",
			component: () =>
				import ("../views/openPlatform/developer/Index.vue"),
			meta: {
				title: "开发者"
			}
		},
			{
				path: '/developerAdd',
				component: () =>
        import ("../views/openPlatform/developer/developerAdd.vue"),
				meta: {
					title: "开发者注册"
				}
			},
			{
				path: "/application",
				component: () =>
					import ("../views/openPlatform/application/Index.vue"),
				meta: {
					title: "应用"
				}
      },
      {
				path: "/applicationRegister",
				component: () =>
					import ("../views/openPlatform/application/applicationRegister.vue"),
				meta: {
					title: "应用注册"
				}
      },
      {
				path: "/applicationModify",
				component: () =>
					import ("../views/openPlatform/application/applicationModify.vue"),
				meta: {
					title: "应用修改"
				}
      },
      {
				path: "/applicationPermission",
				component: () =>
					import ("../views/openPlatform/application/applicationPermission.vue"),
				meta: {
					title: "应用授权API"
				}
			},
			{
				path: "/appoperationRecord",
				component: () =>
					import ("../views/openPlatform/operationRecord/Index.vue"),
				meta: {
					title: "应用操作记录"
				}
			}
		]
	}, {
		path: "/apiList",
		component: () =>
			import("../Layout/index.vue"),
		meta: {
			title: "API权限"
		},
		children: [{
			path: "/apiList",
			component: () =>
				import ("../views/apiPermission/Index.vue"),
			meta: {
				title: "API列表"
			}
		},
    {
      path: "/apiModify",
      component: () =>
        import ("../views/apiPermission/apiModify.vue"),
      meta: {
        title: "API修改"
      }
    }
		]
	}, {
		path: "/mySetting",
		component: () =>
			import("../Layout/index.vue"),
		meta: {
			title: "系统设置"
		},
    children: [
      {
				path: "/roleList",
				component: () =>
					import ("../views/systemSetting/roleManage/Index.vue"),
				meta: {
					title: "角色"
				}
      },
      {
				path: "/roleAdd",
				component: () =>
					import ("../views/systemSetting/roleManage/roleAdd.vue"),
				meta: {
					title: "创建角色"
				}
      },
      {
				path: "/rolePermission",
				component: () =>
					import ("../views/systemSetting/roleManage/rolePermission.vue"),
				meta: {
					title: "角色授权API"
				}
			},
			{
				path: "/roleModify",
				component: () =>
					import ("../views/systemSetting/roleManage/roleModify.vue"),
				meta: {
					title: "角色修改"
				}
      },
      {
				path: "/adminList",
				component: () =>
					import ("../views/systemSetting/adminList/Index.vue"),
				meta: {
					title: "管理员"
				}
      },
      {
				path: "/adminRegister",
				component: () =>
					import ("../views/systemSetting/adminList/adminRegister.vue"),
				meta: {
					title: "管理员注册"
				}
			},
      {
				path: "/adminPermission",
				component: () =>
					import ("../views/systemSetting/adminList/adminPermission.vue"),
				meta: {
					title: "管理员授权API"
				}
			},
			{
				path: "/adminModify",
				component: () =>
					import ("../views/systemSetting/adminList/adminModify.vue"),
				meta: {
					title: "管理员修改"
				}
			},
			{
				path: "/adminSetting",
				component: () =>
					import ("../views/systemSetting/adminList/adminSetting.vue"),
				meta: {
					title: "管理员设置扩展功能"
				}
			},
      {
				path: "/systemParamSetting",
				component: () =>
					import ("../views/systemSetting/systemParamSetting/Index.vue"),
				meta: {
					title: "系统参数设置"
				}
			},
    {
			path: "/mySetting",
			component: () =>
				import ("../views/systemSetting/mySetting/Index.vue"),
			meta: {
				title: "我的设置"
			}
		},
			{
				path: "/systemErrorCode",
				component: () =>
					import ("../views/systemSetting/errorSystemCode/Index.vue"),
				meta: {
					title: "系统错误码"
				}
      },
      {
				path: "/operationRecord",
				component: () =>
					import ("../views/systemSetting/operationRecord/Index.vue"),
				meta: {
					title: "管理员操作记录"
				}
      }
		]
	},
];

const router = createRouter({
	history: createWebHistory(),   //createWebHashHistory
	routes,
});

/*
 * 导航钩子
 * */
router.beforeEach((to, from, next) => {
	//开启进度条
	NProgress.start();
	next();
});

router.afterEach(() => {
	// 关闭进度条
	NProgress.done();
});

export default router;
